package com.tvunetworks.center.device.controller;

import com.tvunetworks.center.common.util.HttpUtil;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.device.model.param.GetChannelParam;
import com.tvunetworks.center.device.service.CustomizedCCService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @program: tvucc-aggregator
 * @description: CustomizedCCController
 * @author lebronchen
 * @create: 2020-04-14 14:01
 **/
@RestController
@RequestMapping("/customizedCC")
public class CustomizedCCController {

    @Autowired
    private CustomizedCCService customizedCCService;

    /**
     *
     * @param param param
     * @param request request
     * @return rid
     */
    @PostMapping("/getChannel")
    public Result getChannel(@RequestBody GetChannelParam param, HttpServletRequest request){
        String ip = HttpUtil.getClientPublicIP(request);
        param.setIp(ip);
        String rid = customizedCCService.getChannel(param);
        return ResultUtil.success(rid);
    }
}
